﻿<%@ Page Title="Graded Test" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="GradedTest.aspx.cs" Inherits="Testify.GradedTest" %>
<%@ MasterType VirtualPath="~/Site.Master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%--<div style="position:absolute;top:0;right:0;width:130px;height:60px;">&nbsp;</div>--%>
<div class="container">
    <asp:Accordion ID="accSegments" runat="server" DataSourceID="dsSegments" CssClass="accSegments">
        <HeaderTemplate>
            <div style="margin: 10px 0px 0px 0px;">
                <a class="takeTest_headerLink">
                    <table class="takeTest_table" style="margin:0px;">
                        <tr>
                            <td align="right" width="30px" class="takeTest_header"><asp:Label ID="lblSegmentNumber" runat="server" Text='<%# Bind("segment_number") %>' /></td>
                            <td class="takeTest_header"><asp:Label ID="lblSegmentHeader" runat="server" Text='<%# Bind("segment_header") %>' /></td>
                        </tr>
                    </table>
                </a>
            </div>
        </HeaderTemplate>
        <ContentTemplate>
            <div class="takeTest_section">
                <asp:HiddenField ID="hdnSegmentID" runat="server" Value='<%# Bind("segment_id") %>' />

                <asp:Label ID="lblSegmentInstructions" runat="server" Text='<%# Bind("segment_instructions") %>' CssClass="takeTest_instructions" />

                <asp:SqlDataSource ID="dsQuestions" runat="server"
                    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                    ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="
SELECT q.*, :p_Offset + rownum || '.' AS question_number,
       '[' || NVL(r.response_credit, 0) || '/' || q.question_weight || '] ' || q.question_text AS question_text_w_credit
  FROM singularity.question q
       LEFT JOIN response r ON (r.question_id   = q.question_id
                            AND r.student_id    = :p_StudentID
                            AND r.assignment_id = :p_AssignmentID)
 WHERE q.segment_id = :p_SegmentID
   AND q.question_maint != 'D'
 ORDER BY q.question_sort_order" onselecting="dsQuestions_Selecting" >
                    <SelectParameters>
                        <asp:Parameter Name="p_Offset" />
                        <asp:ControlParameter ControlID="hdnSegmentID" Name="p_SegmentID" PropertyName="Value" />
                        <asp:SessionParameter Name="p_StudentID" SessionField="UserID" />
                        <asp:SessionParameter Name="p_AssignmentID" SessionField="assign_id" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <asp:GridView ID="grdQuestions" CssClass="takeTest_question" SkinID="none" runat="server" DataSourceID="dsQuestions" 
                    onrowdatabound="grdQuestions_RowDataBound" AutoGenerateColumns="False" 
                    ShowHeader="False" ondatabound="grdQuestions_DataBound" >
                    <Columns>
                        <asp:TemplateField HeaderText="Choices">
                            <ItemTemplate>
                                <asp:HiddenField ID="hdnQuestionID" runat="server" Value='<%# Bind("question_id") %>' />
                                <asp:HiddenField ID="hdnQuestionTypeID" runat="server" Value='<%# Bind("question_type_id") %>' />

                                <table style="margin:10px 0px 0px 12px;">
                                    <tr>
                                        <td align="right"><asp:Label ID="lblQuestionNumber" runat="server" Text='<%# Bind("question_number") %>' /></td>
                                        <td><asp:Label ID="lblQuestionText" runat="server" Text='<%# Bind("question_text_w_credit") %>' /></td>
                                    </tr>
                                </table>

                                <asp:SqlDataSource ID="dsChoices" runat="server"
                                    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                                    ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="
SELECT c.*
  FROM singularity.choice c
 WHERE c.question_id   = :p_QuestionID
   AND c.choice_maint != 'D'
 ORDER BY c.choice_sort_order" />

                                <table>
                                    <col />
                                    <col style="border-left: 2px solid black;" />
                                    <tr>
                                        <th id="thYourResponse"  runat="server" style="color: Red;">Your Response</th>
                                        <th id="thCorrectAnswer" runat="server" style="color: Lime;">Correct Answer</th>
                                    </tr>
                                    <tr id="trTrueFalse" runat="server" visible="false">
                                        <td><asp:RadioButtonList ID="rblTrueFalseResponse" runat="server" RepeatDirection="Horizontal" CssClass="takeTest_choice" Enabled="false" /></td>
                                        <td><asp:RadioButtonList ID="rblTrueFalseAnswer"   runat="server" RepeatDirection="Horizontal" CssClass="takeTest_choice" Enabled="false" /></td>
                                        <%--<td>manual-grading comments</td>--%>
                                    </tr>
                                    <tr id="trMultipleChoice" runat="server" visible="false">
                                        <td><asp:RadioButtonList ID="rblMultipleChoiceResponse" runat="server" CssClass="takeTest_choice" Enabled="false" /></td>
                                        <td><asp:RadioButtonList ID="rblMultipleChoiceAnswer"   runat="server" CssClass="takeTest_choice" Enabled="false" /></td>
                                        <%--<td>manual-grading comments</td>--%>
                                    </tr>
                                    <tr id="trFillInTheBlank" runat="server" visible="false">
                                        <td><asp:TextBox ID="txtFillInTheBlankResponse" runat="server" Columns="20" Enabled="false" /></td>
                                        <td><asp:TextBox ID="txtFillInTheBlankAnswer"   runat="server" Columns="20" Enabled="false" /></td>
                                        <%--<td>manual-grading comments</td>--%>
                                    </tr>
                                    <tr id="trShortAnswer" runat="server" visible="false">
                                        <td><asp:TextBox ID="txtShortAnswerResponse" runat="server" Columns="40" Enabled="false" /></td>
                                        <td><asp:TextBox ID="txtShortAnswerAnswer"   runat="server" Columns="40" Enabled="false" /></td>
                                        <%--<td>manual-grading comments</td>--%>
                                    </tr>
                                    <tr id="trChooseAllThatApply" runat="server" visible="false">
                                        <td><asp:CheckBoxList ID="cblChooseAllThatApplyResponse" runat="server" style="text-align: left;" Enabled="false" /></td>
                                        <td><asp:CheckBoxList ID="cblChooseAllThatApplyAnswer"   runat="server" style="text-align: left;" Enabled="false" /></td>
                                        <%--<td>manual-grading comments</td>--%>
                                    </tr>
                                    <tr id="trMatching" runat="server" visible="false">
                                        <td>
                                            <asp:DropDownList ID="ddlMatchingResponse" runat="server" AppendDataBoundItems="true" Enabled="false">
                                                <asp:ListItem />
                                            </asp:DropDownList>
                                        </td>
                                        <td>
                                            <asp:DropDownList ID="ddlMatchingAnswer"   runat="server" AppendDataBoundItems="true" Enabled="false">
                                                <asp:ListItem />
                                            </asp:DropDownList>
                                        </td>
                                        <%--<td>manual-grading comments</td>--%>
                                    </tr>
                                    <tr id="trPledgeStatement" runat="server" visible="false">
                                        <td><asp:TextBox ID="txtPledgeStatementResponse" runat="server" Enabled="false" /></td>
                                        <td><asp:TextBox ID="txtPledgeStatementAnswer"   runat="server" Enabled="false" /></td>
                                        <%--<td>manual-grading comments</td>--%>
                                    </tr>
                                    <tr id="trEssayResponse" runat="server" visible="false">
                                        <td><asp:TextBox ID="txtEssayResponse" runat="server" TextMode="MultiLine" Columns="80" Rows="8" Enabled="false" /></td>
                                        <td>&nbsp;</td>
                                        <%--<td rowspan="3">manual-grading comments</td>--%>
                                    </tr><%--
                                    <tr id="trCorrectAnswerEssay" runat="server" visible="false">
                                        <th style="color: Lime;">Correct Answer</th>
                                        <td>&nbsp;</td>
                                    </tr>
                                    <tr id="trEssayAnswer"   runat="server" visible="false">
                                        <td><asp:TextBox ID="txtEssayAnswer"   runat="server" TextMode="MultiLine" Columns="80" Rows="8" Enabled="false" /></td>
                                        <td>&nbsp;</td>
                                    </tr>--%>
                                </table>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
            </div>
        </ContentTemplate>
    </asp:Accordion>

    <asp:SqlDataSource ID="dsSegments" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="
SELECT s.*, TO_CHAR(rownum, 'FMRN') || '.' AS segment_number
  FROM singularity.segment s
 WHERE s.test_id = :p_TestID
   AND s.segment_maint != 'D'
 ORDER BY s.segment_sort_order, s.segment_id" >
        <SelectParameters>
            <asp:SessionParameter Name="p_TestID" SessionField="takeTest_id" />
        </SelectParameters>
    </asp:SqlDataSource>
</div>
</asp:Content>